package bold.module.thrift.client;

import bold.module.thrift.genapi.User;
import bold.module.thrift.genapi.UserI;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

import java.util.Arrays;
import java.util.List;

public class Client2 {

    /**
     * 客户端 2
     */
    public static void main(String[] args) throws TException {
        TTransport transport = new TFramedTransport(new TSocket("localhost", 8090, 30000));
        // 协议要和服务端一致
        TProtocol protocol = new TCompactProtocol(transport);
        UserI.Client client = new UserI.Client(protocol);
        transport.open();
        User user = new User((short) 18, true, "刘德华", Arrays.asList("课程1", "课程2", "课程3"));
        List<String> list = client.getList(user);
        System.out.println(list.toString());
        transport.close();
    }
}
